package com.example.acceledemo;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.EditText;

public class SavingName extends Activity{
	
	String accRoute;
	EditText editText;
	

	@Override
	protected void onCreate(Bundle savedInstanceState) {

		requestWindowFeature(Window.FEATURE_NO_TITLE);

		super.onCreate(savedInstanceState);
		setContentView(R.layout.saving);
		
		Bundle type = getIntent().getExtras();
		if (type != null)
			if (type.containsKey("acceleRoute"))
				accRoute = type.getString("acceleRoute");
		
		editText=(EditText) findViewById(R.id.edit_name);
		editText.setText(getDateString());

	}
	
	public void sendMessage(View v)
	{
		
		IOManager.writeStringAsFile(accRoute, editText.getText().toString().concat(".acc"), "MyAcceleDemo");	
		Intent i = new Intent(this, MyTracksList.class);
		finish();
		startActivity(i);

		
	}
	
	public String getDateString()
	{
		DateFormat df = new SimpleDateFormat("dd.MM.yyyy__HH_mm");
		String formattedDate = df.format(new Date()); 
		
		return formattedDate;
	}


}
